package com.diors.game.example.network;

import com.diors.commons.log.DiorsLogger;
import com.diors.commons.network.module.ModuleManager;
import com.diors.game.engine.network.GameServer;
import com.diors.game.example.server.config.NetworkConfig;
import com.diors.game.example.server.controller.PlayerController;

/**
 * 网络层初始化
 * @author	darren.ouyang
 * @data	2013-9-16
 */
public class NetWorkInit 
{

	private DiorsLogger log = DiorsLogger.getLogger(NetWorkInit.class);
	
	private final static NetWorkInit instance = new NetWorkInit();
	
	public static NetWorkInit getInstrance ()
	{
		return instance;
	}
	
	private NetWorkInit(){}
	
	public void init () throws Exception
	{
		/* 初始化网络包 */
		initPacket();
		log.info(">>>>>>>>>>>>>>>>>>初始化网络包");
		
		log.info(">>>>>>>>>>>>>>>>>>初始化命令解析");
		GameServer.init(NetworkConfig.GAME_SERVER_PORT).open();
	}
	
	/**
	 * 初始化网络包
	 * @throws Exception
	 * @create	2013-9-16	darren.ouyang
	 */
	private void initPacket () throws Exception
	{
		ModuleManager.register(ControllerModel.USERMODEL, new PlayerController());
	}
}
